package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.Qualitystandard;
import com.ruoyi.service.IQualitystandardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 质检标准Controller
 * 
 * @author 牢博
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/qualitystandard/qualitystandard")
public class QualitystandardController extends BaseController
{
    @Autowired
    private IQualitystandardService qualitystandardService;

    /**
     * 查询质检标准列表
     */
    @PreAuthorize("@ss.hasPermi('qualitystandard:qualitystandard:list')")
    @GetMapping("/list")
    public TableDataInfo list(Qualitystandard qualitystandard)
    {
        startPage();
        List<Qualitystandard> list = qualitystandardService.selectQualitystandardList(qualitystandard);
        return getDataTable(list);
    }

    /**
     * 导出质检标准列表
     */
    @PreAuthorize("@ss.hasPermi('qualitystandard:qualitystandard:export')")
    @Log(title = "质检标准", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Qualitystandard qualitystandard)
    {
        List<Qualitystandard> list = qualitystandardService.selectQualitystandardList(qualitystandard);
        ExcelUtil<Qualitystandard> util = new ExcelUtil<Qualitystandard>(Qualitystandard.class);
        util.exportExcel(response, list, "质检标准数据");
    }

    /**
     * 获取质检标准详细信息
     */
    @PreAuthorize("@ss.hasPermi('qualitystandard:qualitystandard:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(qualitystandardService.selectQualitystandardById(id));
    }

    /**
     * 新增质检标准
     */
    @PreAuthorize("@ss.hasPermi('qualitystandard:qualitystandard:add')")
    @Log(title = "质检标准", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Qualitystandard qualitystandard)
    {
        return toAjax(qualitystandardService.insertQualitystandard(qualitystandard));
    }

    /**
     * 修改质检标准
     */
    @PreAuthorize("@ss.hasPermi('qualitystandard:qualitystandard:edit')")
    @Log(title = "质检标准", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Qualitystandard qualitystandard)
    {
        return toAjax(qualitystandardService.updateQualitystandard(qualitystandard));
    }

    /**
     * 删除质检标准
     */
    @PreAuthorize("@ss.hasPermi('qualitystandard:qualitystandard:remove')")
    @Log(title = "质检标准", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(qualitystandardService.deleteQualitystandardByIds(ids));
    }
}
